<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<div id="div1">div1</div>
		<div id="div2">div2</div>
		<div id="div3">div3</div>
		<div class="div4">div4</div>
		
		<input type="text" name="qs">
		
		
		
		<script>
			//根据元素名称div获取元素，返回数组
			document.write("<br>");
			var l=document.getElementsByTagName("div");
			document.write(l.length);
			document.write("<br>");
			var qs=document.getElementsByName("qs");
			document.write(qs.length);
			document.write("<hr>");
		</script>
	</body>
</html>